/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.company.regis.db.entity;

import java.io.Serializable;
import java.math.BigInteger;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;

/**
 *
 * @author totoland
 */
@Entity
@Table(name = "REG_ADDRESS")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "RegAddress.findAll", query = "SELECT r FROM RegAddress r")})
public class RegAddress implements Serializable {

    private static final long serialVersionUID = 1L;
    
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id
    @Column(name = "USER_ID", unique = true, nullable = false)
    @GeneratedValue(generator = "gen")
    @GenericGenerator(name = "gen", strategy = "foreign", 
            parameters = @Parameter(name = "property", value = "regUser"))
    private Long userId;
    @Column(name = "ADDRES_DETAIL")
    private String addresDetail;
    @Column(name = "PROVINCE_ID")
    private BigInteger provinceId;
    @Column(name = "AMPHUR_ID")
    private BigInteger amphurId;
    @Column(name = "TUMBOL_ID")
    private BigInteger tumbolId;
    @Column(name = "LAT")
    private BigInteger lat;
    @Column(name = "LON")
    private BigInteger lon;
    @Column(name = "ZIP_CODE")
    private String zipCode;

    @JoinColumn(name = "USER_ID", referencedColumnName = "USER_ID", insertable = false, updatable = false)
    @OneToOne(optional = false,targetEntity = RegUser.class, fetch = FetchType.EAGER)
    private RegUser regUser;

    public RegAddress() {
    }

    public RegAddress(Long userId) {
        this.userId = userId;
    }

    public String getAddresDetail() {
        return addresDetail;
    }

    public void setAddresDetail(String addresDetail) {
        this.addresDetail = addresDetail;
    }

    public BigInteger getProvinceId() {
        return provinceId;
    }

    public void setProvinceId(BigInteger provinceId) {
        this.provinceId = provinceId;
    }

    public BigInteger getAmphurId() {
        return amphurId;
    }

    public void setAmphurId(BigInteger amphurId) {
        this.amphurId = amphurId;
    }

    public BigInteger getTumbolId() {
        return tumbolId;
    }

    public void setTumbolId(BigInteger tumbolId) {
        this.tumbolId = tumbolId;
    }

    public BigInteger getLat() {
        return lat;
    }

    public void setLat(BigInteger lat) {
        this.lat = lat;
    }

    public BigInteger getLon() {
        return lon;
    }

    public void setLon(BigInteger lon) {
        this.lon = lon;
    }

    public String getZipCode() {
        return zipCode;
    }

    public void setZipCode(String zipCode) {
        this.zipCode = zipCode;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public RegUser getRegUser() {
        return regUser;
    }

    public void setRegUser(RegUser regUser) {
        this.regUser = regUser;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 71 * hash + (this.userId != null ? this.userId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final RegAddress other = (RegAddress) obj;
        if (this.userId != other.userId && (this.userId == null || !this.userId.equals(other.userId))) {
            return false;
        }
        return true;
    }

    

    @Override
    public String toString() {
        return "RegAddress{" + "userId=" + userId + ", addresDetail=" + addresDetail + ", provinceId=" + provinceId + ", amphurId=" + amphurId + ", tumbolId=" + tumbolId + ", lat=" + lat + ", lon=" + lon + ", zipCode=" + zipCode + '}';
    }

    

}
